package com.demo.servlet.demo1222.demo01;

import org.junit.Test;

import java.util.Locale;
import java.util.ResourceBundle;

public class Demo01 {
    @Test
    public void test01(){
        //创建语言/地区信息
        Locale locale1 = new Locale("zh","CN");
        Locale locale2 = new Locale("en","US");
        //获取所有可用的语言/地区信息
        Locale[] locales = Locale.getAvailableLocales();
        for (int i = 0; i < locales.length; i++) {
            System.out.println(locales[i]);
        }
    }

    @Test
    public void test02(){
        //读取中文配置文件
        ResourceBundle rb = ResourceBundle.getBundle("res", new Locale("zh", "CN"));
        String username = rb.getString("msg.username");
        String password = rb.getString("msg.password");
        System.out.println(username);
        System.out.println(password);
    }

    @Test
    public void test03(){
        //读取英文配置文件
        ResourceBundle rb = ResourceBundle.getBundle("res", new Locale("en", "US"));
        String username = rb.getString("msg.username");
        String password = rb.getString("msg.password");
        System.out.println(username);
        System.out.println(password);
    }
}
